package com.muyu.danmo.controller;


import com.alibaba.nacos.api.model.v2.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoInformationPhotos;
import com.muyu.danmo.service.IDanmoInformationPhotosService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 个人头像照片Controller
 * 
 * @author yxh
 * @date 2024-11-14
 */
@RestController
@RequestMapping("/photos")
public class DanmoInformationPhotosController extends BaseController
{
    @Autowired
    private IDanmoInformationPhotosService danmoInformationPhotosService;

    /**
     * 查询个人头像照片列表
     */
//    @RequiresPermissions("system:photos:list")
    @GetMapping("/list")
    public com.muyu.common.core.domain.Result<TableDataInfo<DanmoInformationPhotos>> list(DanmoInformationPhotos danmoInformationPhotos)
    {
        startPage();
        List<DanmoInformationPhotos> list = danmoInformationPhotosService.selectDanmoInformationPhotosList(danmoInformationPhotos);
        return getDataTable(list);
    }

    /**
     * 导出个人头像照片列表
     */
//    @RequiresPermissions("system:photos:export")
    @Log(title = "个人头像照片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoInformationPhotos danmoInformationPhotos)
    {
        List<DanmoInformationPhotos> list = danmoInformationPhotosService.selectDanmoInformationPhotosList(danmoInformationPhotos);
        ExcelUtil<DanmoInformationPhotos> util = new ExcelUtil<DanmoInformationPhotos>(DanmoInformationPhotos.class);
        util.exportExcel(response, list, "个人头像照片数据");
    }

    /**
     * 获取个人头像照片详细信息
     */
//    @RequiresPermissions("system:photos:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return Result.success(danmoInformationPhotosService.selectDanmoInformationPhotosById(id));
    }

    /**
     * 新增个人头像照片
     */
//    @RequiresPermissions("system:photos:add")
    @Log(title = "个人头像照片", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoInformationPhotos danmoInformationPhotos)
    {
        return Result.success(danmoInformationPhotosService.insertDanmoInformationPhotos(danmoInformationPhotos));
    }

    /**
     * 修改个人头像照片
     */
//    @RequiresPermissions("system:photos:edit")
    @Log(title = "个人头像照片", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoInformationPhotos danmoInformationPhotos)
    {
        return Result.success(danmoInformationPhotosService.updateDanmoInformationPhotos(danmoInformationPhotos));
    }

    /**
     * 删除个人头像照片
     */
//    @RequiresPermissions("system:photos:remove")
    @Log(title = "个人头像照片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return Result.success(danmoInformationPhotosService.deleteDanmoInformationPhotosByIds(ids));
    }

    @PostMapping("/selectPhotos")
    public    List<DanmoInformationPhotos> selectPhotos(@RequestBody List<Long> longs){
        return danmoInformationPhotosService.selectPhotos(longs);
    }



}
